//
//  JobhunterCell.m
//  APJ HRadar
//
//  Created by Andy liu on 14-4-2.
//  Copyright (c) 2014年 APJ. All rights reserved.
//

#import "JobhunterCell.h"
#import "InterviewCell.h"
#import "Interview.h"
#import "Staff.h"

@implementation JobhunterCell
@synthesize staff,interviewer;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    UIImageView *image=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,522,30)];
    image.backgroundColor=[UIColor clearColor];
    image.image=[UIImage imageNamed:@"123@2x.png"];
    
    name=[[UILabel alloc]initWithFrame:CGRectMake(15,3,80,20)];
    name.backgroundColor=[UIColor clearColor];
    [image addSubview:name];
    
    skill=[[UILabel alloc]initWithFrame:CGRectMake(100,3,120,20)];
    skill.backgroundColor=[UIColor clearColor];
    [image addSubview:skill];
    
    post=[[UILabel alloc]initWithFrame:CGRectMake(280,3,80,20)];
    post.backgroundColor=[UIColor clearColor];
    [image addSubview:post];
    
    reqno=[[UILabel alloc]initWithFrame:CGRectMake(200,3,100,20)];
    reqno.backgroundColor=[UIColor clearColor];
    [image addSubview:reqno];
    
    jobhunter = [[UITableView alloc]initWithFrame:CGRectMake(10,34,522,160) style:UITableViewStylePlain];
    jobhunter.delegate=self;
    jobhunter.dataSource=self;
    
    UIImageView *past=[[UIImageView alloc]initWithFrame:CGRectMake(380,0,100,70)];
    past.backgroundColor=[UIColor clearColor];
    past.image=[UIImage imageNamed:@"finish.png"];
    past.tag=0;
    [self addSubview:image];
    [self addSubview:jobhunter];
    [self addSubview:past];
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return interviewer.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    jobhunter=tableView;
    [tableView registerNib:[UINib nibWithNibName:@"InterviewCell" bundle:nil] forCellReuseIdentifier:@"InterviewCell"];
    
    InterviewCell *cell= [tableView dequeueReusableCellWithIdentifier:@"InterviewCell"];
    
    if (cell == nil) {
        cell = [[InterviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"InterviewCell"];
    }
    
    name.text=staff.chineseName;
    skill.text=staff.techType;
    reqno.text=staff.englishName;
    post.text=staff.jobTitle;
    
    Interview *inskill=[interviewer objectAtIndex:indexPath.row];
    cell.description.text=inskill.comments; //@"对.NET还算比较了解";
    cell.result.text=inskill.interviewStatus;//@"待定";
    if ([inskill.interviewStatus isEqualToString:@"Confirm"]) {
        //cell.backgroundColor=[UIColor blueColor];
    }
    //cell.datetime.text=@"2014-04-01";
    NSDate *time = [NSDate dateWithTimeIntervalSince1970:inskill.interviewTime];
    NSDateFormatter *formate = [[NSDateFormatter alloc] init];
    formate.dateFormat = @"dd-MMM-YYYY";
    cell.datetime.text = [NSString stringWithFormat:@"%@", [formate stringFromDate:time]];
    cell.interviewer.text=inskill.interviewer;//@"richard";
    
    cell.selectionStyle= UITableViewCellSelectionStyleNone;

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 130.0f;
}




@end
